package com.eddie.mediator;

/**
 * @author Eddie
 * @date 2022/08/04 10:52
 **/
public class TV extends MediaObject {


    public TV(Mediator mediator, String name) {
        super(mediator, name);
        //在创建Alarm同事对象时，将自己放入到ConcreteMediator对象中【集合】
        mediator.register(name, this);
    }

    @Override
    public void start() {
        System.out.println("电视打开了");
    }

    @Override
    public void stop() {
        System.out.println("电视关闭了");
    }

    @Override
    public void sendMessage(int stateChange) {
        //调用中介者对象的getMessage
        this.getMediator().getMessage(stateChange, this.name);
    }

    public void sendTV(int stateChange) {
        sendMessage(stateChange);
    }
}
